package com.huchao.www.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;

/**
 * @Description:
 * @BelongsProject: springMVC
 * @BelongsPackage: com.huchao.www.pojo
 * @Author: 亖思
 * @CreateTime: 2022/12/12 17:44
 * @Version: 1.0
 */

@AllArgsConstructor
@NoArgsConstructor
@Data
public class UserSearch implements Serializable {
    private String username;
    private String start;
    private String end;
    public HashMap<String,Object> getHashMap(){
        HashMap<String,Object> map = new HashMap<>();
        if(username!=null && !username.isEmpty()){
            //GET参数中文乱码处理
            username = new String(username.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
            map.put("username",username+"%");
        }
        if(start!=null && !start.isEmpty()){
            map.put("start",start);
        }
        if(end!=null && !end.isEmpty()){
            map.put("end",end);
        }
        return map;
    }
}